<?php
namespace QPHP\core\pdo\intf;

interface IPdo
{

    /**
     * 获取数据库连接
     * @param $dbKey 指定的数据库key:mysql_0
     * @return mixed
     */
    public function getConnect($pool,$connect,$dbKey,$dbType);
    /**
    +----------------------------------------------------------
     * 关闭数据库连接
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     */
    public function close();
    /**
    +----------------------------------------------------------
     * 执行语句 针对 INSERT, UPDATE 以及DELETE
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param string $sql  sql指令
    +----------------------------------------------------------
     * @return boolean
    +----------------------------------------------------------
     */
    public function query($sql);

    /**
    +----------------------------------------------------------
     * 返回操作所影响的行数(INSERT、UPDATE 或 DELETE)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @return integer
    +----------------------------------------------------------
     */
    public function getAffected();

    /**
    +----------------------------------------------------------
     * 获得一条查询记录
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param string  $sql  SQL指令
    +----------------------------------------------------------
     * @return array
    +----------------------------------------------------------
     */
    public function getRow($sql);

    /**
    +----------------------------------------------------------
     * 获得多条查询记录
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param string  $sql  SQL指令
    +----------------------------------------------------------
     * @return array
    +----------------------------------------------------------
     */
    public function getRows($sql);

    /**
    +----------------------------------------------------------
     * 获得最后一次插入的id
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @return int
    +----------------------------------------------------------
     */
    public function getLastInsertId();

    /**
    +----------------------------------------------------------
     * 返回最后一次使用 INSERT 指令的 ID
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @return integer
    +----------------------------------------------------------
     */
    public function getLastInsId();


    /**
    +----------------------------------------------------------
     * 添加数据(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param string  $table  表名
    +----------------------------------------------------------
     * @param array   $arr    插入的数据(键值对)
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
    public function insert($sql);

    /**
    +----------------------------------------------------------
     * 更新数据(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param string  $table  表名
    +----------------------------------------------------------
     * @param array   $arr    更新的数据(键值对)
    +----------------------------------------------------------
     * @param mixed   $where  条件
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
    public function update($sql);

    /**
    +----------------------------------------------------------
     * 删除数据(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param string  $table  表名
    +----------------------------------------------------------
     * @param mixed   $where  条件
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
     public function delete($sql);

    /**
    +----------------------------------------------------------
     * 开启事物(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @param  int  $isXA  是否开启分布式事务
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
    public function startTrans();

    /**
    +----------------------------------------------------------
     * 分布式事物准备(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
    public function prepare($XID);

    /**
    +----------------------------------------------------------
     * 事物提交(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
    public function commit();

    /**
    +----------------------------------------------------------
     * 事物回滚(辅助方法)
    +----------------------------------------------------------
     * @access public
    +----------------------------------------------------------
     * @return mixed
    +----------------------------------------------------------
     */
    public function rollback();
}
